include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/base)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tcpshm)

## 添加include路径下头文件
get_subdir_list(LOCAL_SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "LOCAL_SUBDIRS: ${LOCAL_SUBDIRS}")

# list(APPEND LOCAL_SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND LOCAL_SUBDIRS .)
#list(APPEND LOCAL_SUBDIRS ..)
FOREACH(subdir ${LOCAL_SUBDIRS})
    # include_directories (${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
    message(STATUS "dir：${CMAKE_CURRENT_SOURCE_DIR}/${subdir}")
    FILE(GLOB SUBDIR_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        ${subdir}/*.h
        ${subdir}/*.hpp
    )
    source_group(include\\${subdir} FILES ${SUBDIR_SOURCES})
    list(APPEND LOCAL_HEADERS ${SUBDIR_SOURCES})
ENDFOREACH()
# message(STATUS "LOCAL_HEADERS: ${LOCAL_HEADERS}")

message(STATUS "=======================================================")

## 添加cpp files
FOREACH(subdir ${LOCAL_SUBDIRS})
    FILE(GLOB SUBDIR_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        ${subdir}/*.c
        ${subdir}/*.cpp
    )
    source_group(src\\${subdir} FILES ${SUBDIR_SOURCES})
    list(APPEND LOCAL_SOURCES ${SUBDIR_SOURCES})
ENDFOREACH()

add_library(common STATIC ${LOCAL_HEADERS} ${LOCAL_SOURCES})
# target_link_libraries(${COMMON_LIB} yaml-cpp)
# target_include_directories(${COMMON_LIB} PRIVATE ${CMAKE_SOURCE_DIR}/git-submodules/spdlog/include)
#epm_add_packages_to_target(common yaml-cpp boost)
